<!DOCTYPE html>
<html lang="en">
<head>
    <include file="Public:header2" />
	<title>{:C('web_title')}</title>
</head>
<body class="blackbg">
	<div id="container" class="logbg">
		<!--<div class="reghd">
			<ul>
				<li class="selbut on" id="mobile_reg">手机注册</li>
				<li class="selbut on" id="email_reg">邮箱注册</li>
			</ul>
		</div>-->
		<div class="log_title">
			<span class="back"><a href="javascript:history.go(-1)"></a></span>
			{$Think.lang.Login_register}
		</div>
		<div class="logbot">
			<!--<div id="mobile_div">
				<input type="text" placeholder="手机号" id="mobile" class="logipt" onblur="regmobile()" />
			</div>-->

			<div id="email_div">
				<input type="text" id="email" class="logipt" placeholder="{$Think.lang.g_dz_yx}" onblur="regemail()" />
			</div>

			<div class="yzmbox" id="reg_first_verify">
				<input type="text" id="verify" class="logipt yzmipt" value="" placeholder="{$Think.lang.g_yzm}" onblur="regverify()" maxlength="4"/>
				<img class="codeImg reloadverify" src="{:U('Verify/code')}" title="{$Think.lang.Finance_yzmhyz}" onclick="this.src=this.src+'?t='+Math.random()">
			</div>

			<!--<div class="yzmbox" id="myz_div">
				<input type="text" id="mobilecode" class="logipt yzmipt" value="" onblur="inputcode()" placeholder="短信验证码" maxlength="6"/>
				<input id="regBtn" type="button" class="phonebut" value="点击获取验证码" onclick="SendCode()" />
			</div>-->

			<div class="yzmbox" id="eyz_div">
				<input type="text" id="emailcode" class="logipt yzmipt" value="" onblur="emailcode()" placeholder="{$Think.lang.g_yx_verify}" maxlength="6"/>
				<input id="regBtn" type="button" class="phonebut" value="{$Think.lang.Finance_hqyzm2}" onclick="EmCode()" />
			</div>

			<div class="attention" style="display:none;"><a style="color:red;" href="/Article/notice_detail/id/74.html">收不到邮件怎么办？</a></div>

			<input type="password" id="password" class="logipt" value="" onblur="regpassword()" placeholder="{$Think.lang.Login_dlmmgs}" onkeyup="chkpwd();" maxlength="16"/>

			<input type="password" id="repassword" class="logipt" value="" onblur="regrepassword()" placeholder="{$Think.lang.Login_cfmmgs}" onkeyup="chkrepwd();" maxlength="16"/>

			<input id="invit" name="invite" type="text" class="logipt" placeholder="{$Think.lang.Login_yqmfbt}" value="{$Think.session.invit}" <notempty name="Think.session.invit">readonly</notempty> />

			<input type="hidden" id="reg_type" value="phone" />
			<p class="attention">
                {$Think.lang.Login_zcswty} <a href="/Article/notice_detail/id/91.html" style="color:#059ff5;" target="_blank">{$Think.lang.Login_yhzcxy}</a>
            </p>
			<input type="button" class="logbut" name="index_submit" id="loginSubmin" onclick="Update();" value="{$Think.lang.Login_ljzc}" title="{$Think.lang.Login_ljzc}" />
		</div>
	</div>

<script type="text/javascript">
	function regemail(){
		var email = $('#email').val();
		if(email==""||email==null){
			layer.tips('{$Think.lang.g_yx_put}','#email',{tips:3});
			return false;
		}
		$.post("{:U('Login/chkemail')}",{email:email},function(data){
			if(!data.status){
				layer.tips(data.info,'#email',{tips:3});
			}
		},'json');
	}

	function EmCode(){
		var email = $("#email").val();
        if (email == "" || email == null) {
            layer.tips('{$Think.lang.g_yx_put}', '#email', {tips: 3});
            return false;
        }
		var verify = $('#verify').val();
		if(verify==""||verify==null){
			layer.tips('{$Think.lang.g_put_tcode}', '#verify', {tips: 3});
			return false;
		}
		layer.load(0, {shade: [0.5,'#8F8F8F']});
        $.post("{:U('Verify/regssemail')}", {
            email: email,verify: verify
        }, function (data) {
			layer.closeAll();
            if (data.status == 1) {
                //刷新验证码
                $('#regBtn').attr("disabled", "disabled");
                layer.msg(data.info, {icon: 1});
                var obj = $('#regBtn');
                var wait = 60;
                var interval = setInterval(function () {
                    obj.css('backgroundColor', '#135f91');
                    obj.val(wait + '{$Think.lang.sFinance_myzc_mzcfs}');
                    wait--;
                    if (wait < 0) {
                    	$('#regBtn').removeAttr("disabled");
                        clearInterval(interval);
                        obj.val('{$Think.lang.sFinance_myzc_hqyzm}');
                        obj.css('backgroundColor', '#135f91');
                    }
                    ;
                }, 1000);
            } else {
                //刷新验证码
                layer.msg(data.info, {icon: 2});
                $('#regBtn').removeAttr("disabled");
                if (data.url) {
                    window.location = data.url;
                }
            }
        }, "json");
	}

	function regverify(){
		var verify = $('#verify').val();
		if(verify==""||verify==null){
			layer.tips('{$Think.lang.User_txyzm}','#verify',{tips:3});
			return false;
		}
	}

	function regpassword(){
		var password = $('#password').val();
		if(password==""||password==null){
			layer.tips('{$Think.lang.Finance_srdlmm}','#password',{tips:3});
			return false;
		}
	}

	function regrepassword(){
		var password = $('#password').val();
		var repassword = $('#repassword').val();
		if(repassword==""||repassword==null){
			layer.tips('{$Think.lang.Login_srqrmm}','#repassword',{tips:3});
			return false;
		}else{
			if(password!=repassword){
				layer.tips('{$Think.lang.two_code_diff}','#repassword',{tips:3});
				return false;
			}
		}
	}
	function Update(){
		var reg_type = 'email_a';
		//var mobile=$("#mobile").val();
		var email = $("#email").val();
		var password=$("#password").val();
		var repassword=$("#repassword").val();
		var verify=$("#verify").val();
		var invit=$("#invit").val();
		//var mobilecode=$("#mobilecode").val();
		var emailcode = $("#emailcode").val();
/*		if((mobile==""||mobile==null) && reg_type == 'phone'){
			layer.tips('请输入手机号','#mobile',{tips:3});
			return false;
		}*/
        if (email == "" || email == null) {
            layer.tips('{$Think.lang.g_yx_put}', '#email', {tips: 3});
            return false;
        }
		if(password==""||password==null){
			layer.tips('{$Think.lang.Finance_srdlmm}','#password',{tips:3});
			return false;
		}
		if(repassword==""||repassword==null){
			layer.tips('{$Think.lang.Login_srqrmm}','#repassword',{tips:3});
			return false;
		}
		if(password!=repassword){
			layer.tips('{$Think.lang.two_code_diff}','#repassword',{tips:3});
			return false;
		}
/*		if((mobilecode==""||mobilecode==null) && reg_type == 'phone'){
			layer.tips('请输入手机验证码','#mobilecode',{tips:3});
			return false;
		}*/
		if(emailcode==""||emailcode==null){
			layer.tips('{$Think.lang.g_yx_put_verfy}','#emailcode',{tips:3});
			return false;
		}
		if(verify==""||verify==null){
			layer.tips('{$Think.lang.User_txyzm}','#verify',{tips:3});
			return false;
		}
		$.post("{:U('Login/upregister')}",{reg_type:reg_type,email:email,password:password,repassword:repassword,invit:invit,verify:verify,emailcode:emailcode},function(data){
			if(data.status==1){
				layer.msg(data.info,{icon:1});
				if(reg_type == 'phone'){
					$.cookies.set('cookie_username',mobile);
				}else{
					$.cookies.set('cookie_username',email);
				}
				window.location.href=window.location.href;
			}else{
				layer.msg(data.info,{icon:2});
				if(data.url){
					window.location.href=data.url;
				}
			}
		},"json");
	}
	function regmobile(){
		var mobile = $('#mobile').val();
		if(mobile==""||mobile==null||(mobile!=null&&mobile.length<11)){
			layer.tips('请输入正确的手机号','#mobile',{tips:3});
			return false;
		}
		$.post("{:U('Login/chkmobile')}",{mobile:mobile},function(data){
			if(!data.status){
				layer.tips(data.info,'#mobile',{tips:3});
			}
		},'json');
	}
	function SendCode() {
        var mobile = $("#mobile").val();
        if (mobile == "" || mobile == null) {
            layer.tips('请输入手机号码', '#mobile', {tips: 3});
            return false;
        }
		var verify = $('#verify').val();
		if(verify==""||verify==null){
			layer.tips('请先输入图形验证码', '#verify', {tips: 3});
			return false;
		}
		layer.load(0, {shade: [0.5,'#8F8F8F']});
        $.post("{:U('Verify/regss')}", {
            mobile: mobile,verify: verify
        }, function (data) {
			layer.closeAll();
            if (data.status == 1) {
                //刷新验证码
                $('#regBtn').attr("disabled", "disabled");
                layer.msg(data.info, {icon: 1});
                var obj = $('#regBtn');
                var wait = 60;
                var interval = setInterval(function () {
                    obj.css('backgroundColor', '#135f91');
                    obj.val(wait + '秒再次发送');
                    wait--;
                    if (wait < 0) {
                    	$('#regBtn').removeAttr("disabled");
                        clearInterval(interval);
                        obj.val('获取验证码');
                        obj.css('backgroundColor', '#135f91');
                    }
                    ;
                }, 1000);
            } else {
                //刷新验证码
                layer.msg(data.info, {icon: 2});
                $('#regBtn').removeAttr("disabled");
                if (data.url) {
                    window.location = data.url;
                }
            }
        }, "json");
    }
	function chkpwd(){
		var password = $("#password").val();
		var patten =/^[a-zA-Z0-9]+$/;
		var match = new RegExp(patten);
		if (!match.test(password)) {
			layer.tips('{$Think.lang.User_mmgs2}','#password',{tips:3});
			var result = password.substring(0,password.length-1);
			$("#password").val(result);
		}
	}
	function chkrepwd(){
		var repassword = $("#repassword").val();
		var paypassword = $("#paypassword").val();
		var patten =/^[a-zA-Z0-9]+$/;
		var match = new RegExp(patten);
		if (!match.test(repassword)) {
			layer.tips('{$Think.lang.User_mmgs2}','#repassword',{tips:3});
			var result = repassword.substring(0,repassword.length-1);
			$("#repassword").val(result);
		}
	}
	function inputcode(){
		var mobilecode = $("#mobilecode").val();
		if(mobilecode==""||mobilecode==null){
			layer.tips('请输入短信验证码！','#mobilecode',{tips:3});
			return false;
		}
	}
	function emailcode(){
		var emailcode = $("#emailcode").val();
		if(emailcode==""||emailcode==null){
			layer.tips('{$Think.lang.g_yx_put_verfy}','#emailcode',{tips:3});
			return false;
		}
	}

	$("#mobile_reg").click(function(){
		$(this).attr("class","selbut on");
		$("#mobile_div").show();
		$("#myz_div").show();
		$("#reg_type").val("phone");
		$("#email_reg").attr("class","selbut");
		$("#email_div").hide();
		$("#eyz_div").hide();
		$(".emailtips").hide();
	});
	$("#email_reg").click(function(){
		$(this).attr("class","selbut on");
		$("#mobile_div").hide();
		$("#myz_div").hide();
		$("#reg_type").val("email_a");
		$("#mobile_reg").attr("class","selbut");
		$("#email_div").show();
		$("#eyz_div").show();
		$(".emailtips").show();
	});
</script>
</body>
</html>